package com.gxa.controller;

import com.gxa.common.LayR;
import com.gxa.common.R;
import com.gxa.param.MyTableParam;
import com.gxa.pojo.Baseinfo;
import com.gxa.pojo.Datadictionary;
import com.gxa.service.ddService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author xiejinfeng
 * @create 2021-06-15 22:31
 * @descrip:
 */
@Controller
@RequestMapping("/dd")
public class ddController {
    @Autowired
    private ddService service;

    @PostMapping("/list/Pagedata")
    @ResponseBody
    public LayR list1(MyTableParam param){
        return service.list(param);
    }

    @GetMapping("/list/page")
    public String listPage(){
        return "dd/dd-list";
    }

    @PostMapping("/deleteOne")
    @ResponseBody
    public R deleteOne(Integer id){

        return service.deleteOne(id);
    }

    @PostMapping("/delete")
    @ResponseBody
    public R delete(String[] ddIds){
        return service.deleteAll(ddIds);
    }

    @GetMapping("/add/page")
    public String addPage(){
        return "dd/dd-add";
    }

    @PostMapping("/add/do")
    @ResponseBody
    public R add(Datadictionary datadictionary){

        return service.add(datadictionary);

    }

    @GetMapping("/edit/page")
    public String editPage(Integer id, Model model){
        model.addAttribute("ddId", id);
        return "dd/dd-edit";
    }


    @PostMapping("/detail")
    @ResponseBody
    public R detail(Integer id){
        return service.findById(id);
    }

    @PostMapping("/edit/do")
    @ResponseBody
    public R edit(Datadictionary datadictionary){

        return service.edit(datadictionary);
    }

}
